#include "stdafx.h"

#include "boss.h"

void BOSS::MonsterAI(Character& game,float timepass)
{	
	if(Dead())
	{
		Zero();
		return;
	}
	if(game.Get_HP() <= 0)
	{
		game.Zero();
		Shift(1-rand()%3,1-rand()%3);
	}
	else
	{
		float M = 40*timepass;
		float L, P, Q;
		int ATK=50;
		L = sqrt((game.Get_X()-Get_X())*(game.Get_X()-Get_X())+(game.Get_Y()-Get_Y())*(game.Get_Y()-Get_Y()));
		P = (game.Get_X()-Get_X())/L*M;
		Q = (game.Get_Y()-Get_Y())/L*M;
	
		if(L < MONSTER_SEE+50)
		{	
			if(L < GET_SIZE*2)
				game.BeAttack(ATK);
			else if(L < M)
				SetShift(game.Get_X(),game.Get_Y());
			else
				Shift(P,Q);
		}	
		else
		{
			Shift(1-rand()%3,1-rand()%3);
		}
	}	
}